package thread;

// Fig. Fig. 23.12: UnsynchronizedBuffer.java
// UnsynchronizedBuffer maintains the shared integer that is accessed by 
// a producer thread and a consumer thread via methods set and get.
public class UnsynchronizedBuffer implements Buffer
{
   private int valor = -1; // shared by producer and consumer threads

   // place value into buffer
   public void set( int valor ) throws InterruptedException
   {   System.out.print( "Produziu este valor = " + valor );
       this.valor = valor;
      
      //buffer = value;
   } // end method set

   // return value from buffer
   public int get() throws InterruptedException
   {
      System.err.print( "Consumiu este valor = "+ valor );
      return valor;
   } // end method get
} // end class UnsynchronizedBuffer

